package com.jxwifi.cloud.quickclean.utils;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jxwifi.cloud.quickclean.R;


/**
 * Created by Administrator on 2019/6/5.
 */

public class TitleClient {

    private RelativeLayout mIvLeft;
    private ImageView mImgBackPressed;
    private RelativeLayout mIvRight;
    private ImageView mImgDian;
    private TextView mTitleContent;
    private TextView mTvTextDian;

    public TitleClient(View view) {
        mIvLeft=(RelativeLayout)view.findViewById(R.id.rel_img_back_pressed);
        mImgBackPressed=(ImageView)view.findViewById(R.id.img_back_pressed);
        mIvRight=(RelativeLayout)view.findViewById(R.id.rel_img_dian);
        mImgDian=(ImageView)view.findViewById(R.id.img_dian);
        mTitleContent=(TextView)view.findViewById(R.id.tv_titlebar_text);
        mTvTextDian=(TextView)view.findViewById(R.id.tv_text_dian);
    }

    public void defineTitle(String title) {
        mTitleContent.setText(title);
    }

    public void defineLeft(View.OnClickListener l) {
        mIvLeft.setVisibility(View.VISIBLE);
        mImgBackPressed.setImageResource(R.mipmap.icon_back_black);
        mIvLeft.setOnClickListener(l);
    }

    //右边布局显示与点击事件
    public void defineRigth(int resId,View.OnClickListener l){
        mImgDian.setImageResource(resId);
        mIvRight.setVisibility(View.VISIBLE);
        mIvRight.setOnClickListener(l);
    }

    public void defineTextRight(String StrText,View.OnClickListener l){
        mTvTextDian.setText(StrText);
        mTvTextDian.setVisibility(View.VISIBLE);
        mTvTextDian.setOnClickListener(l);
    }

    public void setTextRightEnable(boolean isEnable){
        mTvTextDian.setEnabled(isEnable);
        mTvTextDian.setClickable(isEnable);
        if (isEnable){
            mTvTextDian.setVisibility(View.VISIBLE);
        }else {
            mTvTextDian.setVisibility(View.INVISIBLE);
        }
    }

}
